/**
 * 定义OnlineMonitorController在线监测管理模块
 */
(function(window, angular, undefined){
	var StationMapModule = angular.module('water.apps.ws.stationMap.stationMapManager', ['ui.router','itfreer','waterCommon','VideoControlService',
	                                                                                     'water.entity.monitorStation','water.entity.district']);
		
	//污染源站点地图
	StationMapModule.controller('WsclcStationMapController',function($state,$itfreer_arcgis_map,$formObject,$gisObject,
			$scope,$waterDataCommon,$wdp,$itfreer_arcgis_search,OperationStationJobService,$VideoService,$rootScope,$monitorStationService,$districtService){
		
		/**
		 * 站点名称查询信息
		 */
		$scope.stationName;
		/**
		 * 政区数据
		 */
		$scope.area;
		/**
		 * 选择的政区
		 */
		$scope.selectArea;
		/**
		 * 站点列表数据
		 */
		$scope.stationList;
		/**
		 * 标识地图鼠标事件是否注册
		 */
		$scope.graphicLayerEventRegist = false;
		/**
		 * 选择的站点
		 */
		$scope.selectStation;
		//地图复位
		if( $gisObject.map){
			$gisObject.map.setExtent($gisObject.fullExtent);
		}
		//去掉视频延迟函数
		if($wdp.timeout){
			clearTimeout($wdp.timeout); 
		}
		//根据权限显示地图
		setTimeout(function () {
			if($rootScope.currentUser){
			var userid=$rootScope.currentUser.C_USERNAME;
			$itfreer_arcgis_map.setServices("qhhf",false);
			if(userid.indexOf("qu") > 0){
				$itfreer_arcgis_map.setServices("sz",false);
				$itfreer_arcgis_map.setServices("LYXS",false);
				$itfreer_arcgis_map.setServices("SX",false);
				if(userid=='baoanqu'){
					$itfreer_arcgis_map.setServices("qh_baoan",true);
					var extent = new esri.geometry.Extent({
						"xmin" : 64264.23942567059,
						"ymin" : 29130.064984465826,
						"xmax" : 133056.0436759458,
						"ymax" : 62136.90183147288,
						"spatialReference" :  $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				if(userid=='nanshanqu' ){
					$itfreer_arcgis_map.setServices("qh_nanshan",true);
					var extent = new esri.geometry.Extent({
						"xmin" : 84347.7850175417,
						"ymin" : 14898.049748109574,
						"xmax" : 122263.4640058958,
						"ymax" : 33090.28418579102,
						"spatialReference" : $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				if(userid=='guangmingxinqu' ){
					$itfreer_arcgis_map.setServices("qh_guangming",true);
					var extent = new esri.geometry.Extent({
						"xmin" : 89115.92850922374,
						"ymin" : 40023.308776781036,
						"xmax" : 115658.70436431142,
						"ymax" : 52758.736807250985,
						"spatialReference" : $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				if(userid=='dapengxinqu' ){
					$itfreer_arcgis_map.setServices("qh_dapeng",true);
					var extent = new esri.geometry.Extent({
						"xmin" :138116.69768078666,
						"ymin" : 14819.935345130603,
						"xmax" : 178709.80537097115,
						"ymax" : 34296.820669555666,
						"spatialReference" : $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				if(userid=='pingshanqu' ){
					$itfreer_arcgis_map.setServices("qh_pingshan",true);
					var extent = new esri.geometry.Extent({
						"xmin" :130311.91155582221,
						"ymin" : 30242.965887515664,
						"xmax" : 164707.81368095978,
						"ymax" : 46746.38431101918,
						"spatialReference" : $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				if(userid=='yantianqu' ){
					$itfreer_arcgis_map.setServices("qh_yantian",true);
					var extent = new esri.geometry.Extent({
						"xmin" :124842.08298367113,
						"ymin" : 22045.54857390939,
						"xmax" : 146855.4603437592,
						"ymax" : 32607.736364951637,
						"spatialReference" : $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				if(userid=='longgangqu' ){
					$itfreer_arcgis_map.setServices("qh_longgang",true);
					var extent = new esri.geometry.Extent({
						"xmin" :105538.16441836767,
						"ymin" : 26314.32025540909,
						"xmax" : 160571.6078185878,
						"ymax" : 52719.78973301472,
						"spatialReference" : $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				if(userid=='longhuaqu' ){
					$itfreer_arcgis_map.setServices("qh_longha",true);
					var extent = new esri.geometry.Extent({
						"xmin" :100122.36789953068,
						"ymin" : 28469.33757508427,
						"xmax" : 134518.27002466825,
						"ymax" : 44972.75599858779,
						"spatialReference" : $gisObject.tywkid
					});
					$gisObject.map.setExtent(extent);
				}
				
			 }
			else{
					$itfreer_arcgis_map.setServices("sz",true);
					$itfreer_arcgis_map.setServices("LYXS",true);
					$itfreer_arcgis_map.setServices("SX",true);
				}
			}
			}, 100);
		
		/**
		 * 加载政区数据
		 */
		function _initArea(){
			$districtService.getDistrictDomain().then(function(data){
				$scope.area = data.qu;
			});
		}
		/**
		 * 政区选择事件
		 */
		$scope.onAreaChange = function(area){
			var extent = new esri.geometry.Extent(area.MINX,area.MINY,area.MAXX,area.MINY,$gisObject.map.spatialReference);
			$scope.queryStation();
			if($scope.selectArea == 'all'){
				$gisObject.map.setExtent($gisObject.fullExtent);
			}
			else{
				$gisObject.map.setExtent(extent);
			}
		}
		function showwinVideo(str,station_id){
			//判断浏览器
			var brow=$.browser;
			if(brow.msie) { 
			 }
			else if(brow.mozilla)  {
			}
			else{
				alert("请使用IE 9-IE 11浏览器访问!");
				return;
			}
			//判断网络
			var sysurl=window.location.href;
			if(sysurl.indexOf("223.2") > 0 ||sysurl.indexOf("218")>0||sysurl.indexOf("localhost")>0){
			    
			}
			else{
				alert("现使用网络和视频不在同一网络!");
				return;
			}
         	     $(".esriPopup .sizer").css("width","800px");
				 $(".gis_win_left").css("height","400px");
				 $(".gis_win_right").css("display","block");
         	if (-1 == WebVideoCtrl.I_CheckPluginInstall()) {
				     window.open(getJsBasePath()+"wdp/ws/WebComponents.exe");
				     return;
			      }
				// 初始化插件参数及插入插件
			  	WebVideoCtrl.I_InitPlugin(380, 280, {
			          iWndowType: 1,
			  		  cbSelWnd: function (xmlDoc) {
			  			  
			  		}
			  	});
				 WebVideoCtrl.I_InsertOBJECTPlugin("windivPlugin");
				 $waterDataCommon.getPageRows("/VideoController/getStationData.do","list",{station_id:station_id,VIDEO_POSITION:str},6,1,function(result){
             		if(result.data.length>0){
						 var obj=result.data[0];
						 $VideoService.clickLogin(obj.IP,obj.PORT,obj.USER_ID,obj.PASSWORD,0);
					  }
             	});
				 
         };
         //控制图片点击显示视频
         $scope.VideoClick=false;
		//视频图片点击事件
		$scope.videoClick=function(data){
			//定义中心点
			var centerPoint = new esri.geometry.Point();
			//设置空间参考
			centerPoint.setSpatialReference($gisObject.map.spatialReference);
			
			//获取当前地图坐标范围和中心点，用于计算需要偏移多少
			var extent = $gisObject.map.extent;
			var center = $gisObject.map.extent.getCenter();
			//目标点横坐标距离左边的偏移量
			var dx = (extent.xmax - extent.xmin) / 10;
			//中心点的偏移量
			var hx = center.x - extent.xmin - dx;
			//设置中心点坐标
			centerPoint.setX(data.X + hx);
			centerPoint.setY(data.Y);
			//设置中心点
			$gisObject.map.centerAt(centerPoint);
			setTimeout(function () {
				var graphic =  $scope._createFeatureFromStation(data);
				$scope.VideoClick=true;
				onGraphicClick(graphic);
			},500);
		};
		//是否显示视频图片
		$scope.showVideoPic=function(data){
			var list=$scope.videoDataForShow;
			var b=false;
			if(data){
				for(var i=0;i<list.length;i++){
				var obj=list[i];
				if(obj.STATION_CODE==data.EXP_NO){
					b=true;
				}
			 }
			}
			return b;
		};
		
		function onGraphicClick(graphic){
			$scope.showAllStationData = false;
			$gisObject.map.infoWindow.setTitle(getInfoTemplateTitle(graphic));
			setContentAndShow(graphic);
		}
		
		function getInfoTemplateTitle(feature){
			var o = feature.attributes;
			var name = o.NAME;
			if(o.$searchName=='wsc'){
				name=o['SDE.PS_WWTPM.NAME'];
			}
			var title = '<b>' + name + '</b>';
			if(o.$searchName=='station'){
				title += '&nbsp;&nbsp<a id="btnDetail" style="cursor:pointer;color:#3d6dcc;text-decoration:none">详情»</a>';
				$('.esriPopup').undelegate('#btnDetail',"click").delegate('#btnDetail',"click",function(event){
					$scope.openStationDetailWindow(feature);
					$scope.safeApply();
				});
			}
			return title;
		}
		
		function setContentAndShow(feature){
			    $gisObject.map.infoWindow.resize(410,400);
				setContentAndShow_Station(feature);
		}
		
		/**
		 * 控制实时数据滚动
		 */
		function tableScroll(){ 
			 angular.element("#dataTableContent").bind("scroll", function(e) {
				 var top=document.getElementById("dataTableContent").scrollTop; 
					var left=document.getElementById("dataTableContent").scrollLeft; 
					document.getElementById("datatimeCloumn").scrollTop=top; 
					document.getElementById("dataHeadContent").scrollLeft=left; 
			   })
		} 
		tableScroll();
		//设置视图事件
		function setContentAndShow_Station(feature){
			var o = feature.attributes;
			var downloadUrl = getBasePath()+'/plupload/download.do';
			var image= getJsBasePath()+ 'wdp/images/noPic.png';
			var searcimg = getJsBasePath()+ 'wdp/images/zs-search-nb.png';
			var video="";
			
			OperationStationJobService.postQuery("/RemoteControl/getStationInfo.do",{mn:o.DEVICE_NUM}).then(function(data){
				if(o.PHOTO){
					image = getHostBase() + firstImgUrl(o.PHOTO);
				}
				//重置样式
				$(".gis_win_left").css("display","none");
				$(".esriPopup .sizer").css("width","350px");
				$(".esriPopup .contentPane").css("max-height","330px");
				/**视频 开始**/
				//站内视频
				$('.esriPopup').undelegate('#VideoIn',"click").delegate('#VideoIn',"click",function(event){
					showwinVideo('0',o.EXP_NO);
				});
				//站外视频
                $('.esriPopup').undelegate('#VideoOut',"click").delegate('#VideoOut',"click",function(event){
                	showwinVideo('1',o.EXP_NO);
				});
               
				/**视频结束**/
				
				$('.esriPopup').undelegate('li',"click").delegate('li',"click",function(event){
					$('.esriPopup #radius').val(parseInt($(this)[0].innerText));
				});
				$('.esriPopup').undelegate('#searchWSC',"click").delegate('#searchWSC',"click",function(event){
					var inputRadius = $('.esriPopup #radius').val();
					var radius = parseFloat(inputRadius);
					if(isNaN(radius)){
						$.messager.alert('提示','请输入正确的搜索半径!');
						return;
					}
					
					var keyWord = $('.esriPopup #keyWord').val();
					var queryObj = {};
					queryObj.url = "http://202.105.247.6:6080/arcgis/rest/services/PS_WWTPM/MapServer/0";
					queryObj.geometry = feature.geometry;
					queryObj.radius = radius;
					if(keyWord!=''){
						queryObj.where = "SDE.PS_WWTPM.NAME like '%"+keyWord+"%'";
					}
					$itfreer_arcgis_search.neighborSearch('wsc',queryObj,onGraphicClick,function(data){
						if(data && data.length>0){
							$wdp.viewValue.hasSearchResult = true;
							$gisObject.map.graphics.hide();
							$gisObject.map.infoWindow.hide();
							$scope.safeApply();
						}
					});
				});
				$('.esriPopup').undelegate('#searchStation',"click").delegate('#searchStation',"click",function(event){
					var inputRadius = $('.esriPopup #radius').val();
					var radius = parseFloat(inputRadius);
					if(isNaN(radius)){
						$.messager.alert('提示','请输入正确的搜索半径!');
						return;
					}
					
					var keyWord = $('.esriPopup #keyWord').val();
					var queryObj = {};
					queryObj.url = "http://202.105.247.6:6080/arcgis/rest/services/MONITOR_STATION/MapServer/1";
					queryObj.geometry = feature.geometry;
					queryObj.radius = radius;
					if(keyWord!=''){
						queryObj.where = "NAME like '%"+keyWord+"%'";
					}
					$itfreer_arcgis_search.neighborSearch('station',queryObj,onGraphicClick,function(data){
						if(data && data.length>0){
							$wdp.viewValue.hasSearchResult = true;
							$gisObject.map.graphics.hide();
							$gisObject.map.infoWindow.hide();
							$scope.safeApply();
						}
					});
				});
				var alldata=data;
				$waterDataCommon.getPageRows("/OnlineMonitor/getVideoData.do","videoList",{"WWTP_ID":o.WWTP_ID,"STATION_ID":o.CODE},10,1,function(d){
					if(d.data.length>0){
						for(var i=0;i<d.data.length;i++){
							 var obj=d.data[i];
							 if(obj.VIDEO_POSITION=='0'){
								 video+='<a style="cursor:pointer;text-decoration:none" id="VideoIn">&nbsp;&nbsp;&nbsp;&nbsp;站房视频</a>'; 
							 }
							 if(obj.VIDEO_POSITION=='1'){
								 video+='<a style="cursor:pointer;text-decoration:none" id="VideoOut">&nbsp;&nbsp;&nbsp;&nbsp;采样视频</a>'; 
							 }
						}
						
					}
					$gisObject.map.infoWindow.setContent(getGISWindowsHTML(image,o.STATUS,alldata.parmData,video));
					$gisObject.map.infoWindow.show(feature.geometry);
					if($scope.VideoClick){
						showwinVideo('0',o.EXP_NO);
						$scope.VideoClick=false;
					}
				});
			});
			return;
		}
		//设置弹出框内容
		function getGISWindowsHTML(image,onlineStatus,pollData,video){
			var parm = '';
			if(pollData){
				angular.forEach(pollData,function(value,key){
					if(!value.MEAS){
						return;
					}
					parm += "<tr> ";
					parm += " <td> " + value.POLLNAME+':</td><td>'+value.MEAS+""+ value.UNIT + "</td>";
					parm += "</tr> ";
				});
			}
			
			var status=(onlineStatus=='1'? '<span class="zx"></span>在线':'<span class="lx"></span>离线');
			
			var html = '<div class="gis_win_main" style="font-size: 12px;font-family: \'Microsoft YaHei\', verdana, tahoma;">'+
						   '<div class="gis_win_left" style="float:left;width:338px">'+
								  '<div style="float:left;">'+
									'<div style="float:left;">'+
										'<img onclick="imgShow($(this))" style="cursor:pointer;width:130px;height:195px;" src="'+image+'" />'+
									'</div>'+
									'<div style="float:left;padding-left:1px;">'+
										' <div style="overflow:auto;height:210px;">'+
											'  <table style="min-width:190px;" class="zs-form-tab" id="stationPollData">	'+
											'<tbody>'+parm+'</tbody>'+
											 ' </table>'+
										 '</div>'+
									'</div>	'+
							  ' </div>'+
							   /*'<div class="text tip" style="clear:both;margin:5px 0px 5px 0px;float:left;">'+
									'站点状态：'+status+
							   '</div>'+*/
							   '<div class="tip" style="border-top:solid 1px #ECECEC;float:left">'+
									'<div style="width:330px;margin:1px 0px 1px 0px">'+
										' <div style="float:left">'+
										'	<img style="vertical-align: middle;" src="'+getJsBasePath()+ 'wdp/images/zs-search-nb.png" />'+
											'<span>在周边找</span>&nbsp;&nbsp;&nbsp;'+video+
										' </div>'+
										' <input style="float:left;clear:left;margin:1px 0px 1px 0px;width:120px;height:11px;" id="radius" type="text" class="zs-input" placeholder="搜索半径(公里)" />&nbsp;&nbsp;&nbsp;'+
										' <ul style="float:left;vertical-align: middle;margin:-5px 0px 1px 0px;" class="zs-data-sizer">'+
										'	  <li><a style="cursor:pointer;text-decoration:none">10公里</a></li>'+
										'	  <li><a style="cursor:pointer;text-decoration:none">20公里</a></li>'+
										'	  <li><a style="cursor:pointer;text-decoration:none">30公里</a></li>'+
										 '</ul>'+
										 '<div style="margin:1px 0px 1px 0px;float:left;">'+
											'  <input id="keyWord" type="text" class="zs-input" placeholder="关键字" style="width:120px;;height:11px;" />&nbsp;&nbsp;&nbsp;'+
											 ' <input style="vertical-align: top;" id="searchWSC" type="button" class="zs-btn" value="污水厂" />&nbsp;&nbsp;'+
											  '<input style="vertical-align: top;" id="searchStation" type="button" class="zs-btn" value="站点" />'+
										 '</div>'+
									'</div>'+
							   '</div>'+
						   '</div>'+
						  ' <div class="gis_win_right" style="width:384px;height:300px;float:left;display:none">'+
								'<div id="windivPlugin" ></div>'+
						  ' </div>	 '+
					 ' </div>';
			return html;
		}
		//取一张图片
		function firstImgUrl(url){
			if(url.indexOf("|") > 0)
			{
				 var arr = url.split("|");
				 return String(arr[arr.length-1].toString().split(":")[0]);
		    }
			 else{
				 var arr = url.split(":");
				return String(arr[0]);
			 }
		}

		//用于判断是否有视频
		$scope.videoDataForShow={};
		/**
		 * 获取查询参数
		 */
		$scope._getQueryObject = function(){
			var waterType = getWaterType();
			var queryObj = {
					DISTRICT:$scope.selectArea,
					WATER_TYPE:waterType,
					BUILD_STATUS:'0',
					STATION_NAME:$scope.stationName
			};
			if($scope.selectArea == 'all'){
				delete queryObj.DISTRICT;
			}
			return queryObj;
		}
		$scope.queryStation=function(){
			 var obj=$scope._getQueryObject();
			$monitorStationService.getListWithCompany(obj).then(function(data){
				
				$scope.stationList = data.data;
				$scope._renderToMap(data.data);
				$scope._registerGraphicMouseEvent();
			});			
			//获取所有视频数据 ,用于判断显示视频
			$waterDataCommon.getPageRows("/OnlineMonitor/getVideoData.do","videoList",{"WWTP_ID":"","STATION_ID":""},10,1,function(d){
				if(d.data.length>0){
					$scope.videoDataForShow=d.data;
				}
				else{
					$scope.videoDataForShow={};
				}
			});
		};
		/**
		 * 把站点数据转换成feature添加到地图上
		 */
		$scope._renderToMap = function(data){
			if($gisObject.map.graphics){
				$gisObject.map.graphics.clear();
				$gisObject.map.infoWindow.hide();
			}
			
			for(var i=0;i<data.length;i++){
				var item = data[i];
				var graphic = $scope._createFeatureFromStation(item);
				$gisObject.map.graphics.add(graphic);
			}
		};
		
		/**
		 * 通过station数据构造feature
		 */
		$scope._createFeatureFromStation = function(station){
			var point = new esri.geometry.Point({
				 x:station.X,
				 y:station.Y,
				 spatialReference:$gisObject.map.spatialReference
				});  
			var defaultSymbol = $scope._getDefaultSymbol(station);
			var heightLightSymbol = $scope._getHighlightSymbol();
			var graphic =  new esri.Graphic(point,defaultSymbol,{});
			graphic.attributes = station;
			graphic.defaultSymbol = defaultSymbol;
			graphic.heightLightSymbol = heightLightSymbol;
			return graphic;
		};
		/**
		 * 注册graphic的鼠标事件
		 */
		$scope._registerGraphicMouseEvent = function(){
			if(!$scope.graphicLayerEventRegist){
				//dojo.connect($gisObject.map.graphics, "onMouseOver", $scope.onGraphicMouseOverOrLeave);
				//dojo.connect($gisObject.map.graphics, "onMouseOut", $scope.onGraphicMouseOverOrLeave);
				dojo.connect($gisObject.map.graphics, "onClick", $scope.onGraphicClick);
				$scope.graphicLayerEventRegist = true;
			}
		}
		/**
		 * Graphi的鼠标悬浮或者离开事件
		 */
		$scope.onGraphicMouseOverOrLeave = function (evt){
	    	var graphic = evt.graphic;
	    	
    		if(evt.type==="mouseover"){
	    		$gisObject.map.setMapCursor("pointer");
	    		graphic.setSymbol(graphic.heightLightSymbol);
	    	}
	    	else{
	    		$gisObject.map.setMapCursor("default");
	    		graphic.setSymbol(graphic.defaultSymbol);
	    	}
	    }
		/**
		 * 地图Graphic鼠标点击事件
		 */
		$scope.onGraphicClick = function(evt){
			var graphic = evt.graphic;
			$scope.showAllStationData = false;
			$gisObject.map.infoWindow.setTitle(getInfoTemplateTitle(graphic));
			setContentAndShow(graphic);
		}
		/**
		 * 根据站点的状态获取地图样式
		 */
		$scope._getDefaultSymbol = function(data){
			var imgUrl = "online.png";
			if(data.STATION_STATUS == null ||data.STATION_STATUS == ""){
				imgUrl = "3.png";
			}
			else{
				imgUrl = data.STATION_STATUS+".png";
			}
			var symbol = new esri.symbol.PictureMarkerSymbol(getJsBasePath()+"wdp/images/stationStatus/"+imgUrl,15,15);
			return symbol;
		}
		/**
		 * 高亮符号
		 */
		$scope._getHighlightSymbol = function(){
			var iconURL = getJsBasePath()+"/wdp/images/highlight.png";
			var pMark = new esri.symbol.PictureMarkerSymbol(iconURL, 20, 20);
			return pMark;
		}
		/**
		 * 站点定位点击事件
		 */
		$scope.onLocateClick = function(station){
			var graphic = $scope._createFeatureFromStation(station);
			$gisObject.map.centerAndZoom(graphic.geometry,4);
		}
		/**
		 * 站点列表项点击事件
		 */
		$scope.onStationClick = function(station){
			$scope.selectStation = station;
			var graphic =  $scope._createFeatureFromStation(station);
			$gisObject.map.centerAndZoom(graphic.geometry,4);
			onGraphicClick(graphic);
		}
		
		/**
		 * 站点详情
		 */
		$scope.openStationDetailWindow = function(data){
			$("#stationmapclass .list").removeClass("selected");
			$("div.list[wwtpid='"+data.attributes["EXP_NO"]+"']").addClass("selected");
			
			var no = data.attributes["SDE.PS_WWTPM.EXP_NO"];
			var stationExpNo = data.attributes["CODE"];
			$wdp.viewValue.wwtpDetailParm={WWTPID:no,STATION_ID:stationExpNo};
			$formObject.isMIS = true;
			$("#wsclcXQTabLi").hide();
			$("#baxx").hide();
			$("#wsclcdetailmain .idTabs" ).idTabs();
			$("#backToMapBtn").show();
			$("#backToMapBtn").unbind("bind").bind("click",function(){
				$scope.safeApply(function(){
					$formObject.isMIS = false;
				});
				$("#backToMapBtn").hide();
			});
		}
		
		/**
		 * 判断是否显示视频按钮
		 */
		$scope.isVideoShow=function(data){
			var list=$scope.videoDataForShow;
			var b=false;
			if(data.attributes){
				for(var i=0;i<list.length;i++){
				var obj=list[i];
				if(obj.STATION_CODE==data.attributes.EXP_NO){
					b=true;
				}
			 }
			}
			return b;
		};
		if($gisObject.mapInit && $gisObject.map.graphics != null){
			$scope.queryStation();
        }else{
        	var mapInitWatch = $scope.$watch(function(){return $gisObject.mapInit;},function(){
	            if($gisObject.mapInit){
	            	$scope.queryStation();
	            	mapInitWatch();
	            }
	        });
        }
		_initArea();
	});
	
	//污染源站点地图
	StationMapModule.controller('mapController',function($rootScope,$state,$gisObject,$formObject,$scope,$waterDataCommon,$wdp){

		if($wdp.viewValue.isMisWatch){
			$wdp.viewValue.isMisWatch();
		}
		$wdp.viewValue.isMisWatch = $rootScope.$watch(function(){return $formObject.isMIS;},function(){
			$scope.showAllStationData = false;
        },true);
		
		$scope.showAllStationData = false;
		var pollToChecked = "001,011,060,101,phe,028,023,031,065,cond,phtem,015";
		
		$scope.showAllStationDataList = function(){
			$scope.showAllStationData = !$scope.showAllStationData;
			$gisObject.map.infoWindow.hide();
			if($scope.showAllStationData){
				$scope.getAllStationDataList();
			}
		}
		
		$scope.getAllStationDataList = function(){
			$waterDataCommon.getPageRows("/DataReport/AllStationRealTimeData.do","ReportList",{"parmToChecks":pollToChecked},1,1);
		}
		
		$scope.closeAllStationData = function(){
			$scope.showAllStationData = false;
		}
	});
}(window, angular));
